﻿/*
Copyright 2010 Shane Ng

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using java.io;

namespace Jeans
{
    internal class JavaInputStream : InputStream
    {
        public Stream wrapped;
        public JavaInputStream(Stream s)
        {
            wrapped = s;
        }

        public override int read()
        {
            return wrapped.ReadByte();
        }

        public override void close()
        {
            wrapped.Close();
        }

        public override void reset()
        {
            wrapped.Seek(0, SeekOrigin.Begin);
        }

        public override long skip(long n)
        {
            return wrapped.Seek(n, SeekOrigin.Current);
        }

        public override bool markSupported()
        {
            return false;
        }

        protected override void  finalize()
        {
            wrapped.Dispose();
        }

        public override void mark(int readlimit)
        {
            throw new NotSupportedException();
        }

        public override int read(byte[] b)
        {
            return wrapped.Read(b, 0, b.Length);
        }

        public override int read(byte[] b, int off, int len)
        {
            return wrapped.Read(b, 0, b.Length);
        }

        protected override object clone()
        {
            throw new NotSupportedException();            
        }
    }
}
